//package com.plian.system.service.hr.employment.impl;
//
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.entity.hr.employment.AdmissionResultEntity;
//import com.plian.system.entity.hr.employment.AdmissionResultInfoEntity;
//import com.plian.system.mapper.hr.employment.AdmissionResultMapper;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.service.hr.employment.IAdmissionResultInfoService;
//import com.plian.system.service.hr.employment.IAdmissionResultService;
//import com.plian.system.vo.hr.employment.AdmissionResultInfoVO;
//import com.plian.system.vo.hr.employment.AdmissionResultVO;
//import com.plian.system.wrapper.hr.employment.AdmissionResultInfoWrapper;
//import com.plian.system.wrapper.hr.employment.AdmissionResultWrapper;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//import java.util.Optional;
//
//import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;
//
///**
// * 拟录取结果公示 服务实现类
// *
// * @author gangan
// * @since 2023-05-23
// */
//@Service
//@AllArgsConstructor
//public class AdmissionResultServiceImpl extends BaseServiceImpl<AdmissionResultMapper, AdmissionResultEntity> implements IAdmissionResultService {
//
//    private AdmissionResultWrapper admissionResultWrapper;
//
//    private IAdmissionResultInfoService admissionResultInfoService;
//
//    private AdmissionResultInfoWrapper admissionResultInfoWrapper;
//
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveOrUpdate(AdmissionResultEntity entity) {
//        if (entity.getId() == null) {
//            entity.setFormType(String.valueOf(FormTypeConstant.HR_ADMISSION_RESULT));
//            entity.setStatus(UNREVIEWED);
//        }
//        return super.saveOrUpdate(entity);
//    }
//
//    @Override
//    public AdmissionResultVO getDetail(AdmissionResultEntity admissionResult) {
//        AdmissionResultVO admissionResultVO = admissionResultWrapper.entityToVO(admissionResult);
//        List<AdmissionResultInfoEntity> childList = admissionResultInfoService.list(Wrappers.<AdmissionResultInfoEntity>lambdaQuery()
//                .eq(AdmissionResultInfoEntity::getBaseResultId, admissionResult.getId()));
//        admissionResultVO.setChildList(admissionResultInfoWrapper.entityToVO(childList));
//        return admissionResultVO;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean submit(AdmissionResultVO admissionResultVO) {
//        AdmissionResultEntity entity = admissionResultWrapper.voToEntity(admissionResultVO);
//        boolean result = saveOrUpdate(entity);
//        List<AdmissionResultInfoVO> childList = admissionResultVO.getChildList();
//        if (CollectionUtil.isNotEmpty(childList)) {
//            for (AdmissionResultInfoVO child : childList) {
//                if (child.getId() != null && Optional.ofNullable(child.getIsDeleted()).isPresent() && child.getIsDeleted().intValue() == 1) {
//                    admissionResultInfoService.removeById(child.getId());
//                } else {
//                    child.setBaseResultId(entity.getId());
//                    admissionResultInfoService.saveOrUpdate(child);
//                }
//            }
//        }
//        return result;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean deleteLogic(List<Long> ids) {
//        boolean result = super.deleteLogic(ids);
//        if (result) {
//            admissionResultInfoService.deleteLogicByParentId(ids);
//        }
//        return result;
//    }
//}
